package com.weishi.project.sport.world.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.weishi.framework.web.domain.AjaxResult;
import com.weishi.project.sport.world.service.WorldService;
import com.weishi.project.training.domain.WorldAchievement;
import com.weishi.project.training.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * 运动员 首页信息模块 接口实现类
 */
@Service
public class WorldServiceImpl implements WorldService {

    /**
     * 运动员 世界成绩
     */
    @Autowired
    private IWorldAchievementService worldAchievementService;


    /**
     * 运动员 -- 世界成绩只查询水上专项 2000 米 ， 根据不同艇只，男女 ，来查询
     */
    @Override
    public AjaxResult getWorldAchievement(Integer sportId , String sex) {
        return AjaxResult.success(worldAchievementService.list(Wrappers.<WorldAchievement>lambdaQuery().eq(WorldAchievement::getSex , sex).orderByDesc(WorldAchievement::getAchievement)));
    }


    /**
     * 运动员 -- 新增世界成绩
     */
    @Override
    public AjaxResult addWorldAchievement(WorldAchievement worldAchievement) {
        worldAchievement.setCtime(new Date());
        worldAchievementService.save(worldAchievement);
        return AjaxResult.success();
    }









}
